home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / IO::Socket.Z / IO::Socket
Encoding:
Text File  |  1998-10-28  |  9.9 KB  |  331 lines

  1.  
  2.  
  3.  
  4.      IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       IO::Socket - Object interface    to socket communications
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.           use IO::Socket;
  13.  
  14.  
  15.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  16.       IO::Socket provides an object    interface to creating and
  17.       using    sockets. It is built upon the the _I_O::_H_a_n_d_l_e manpage
  18.       interface and    inherits all the methods defined by the
  19.       _I_O::_H_a_n_d_l_e manpage.
  20.  
  21.       IO::Socket only defines methods for those operations which
  22.       are common to    all types of socket. Operations    which are
  23.       specified to a socket    in a particular    domain have methods
  24.       defined in sub classes of IO::Socket
  25.  
  26.       IO::Socket will export all functions (and constants) defined
  27.       by the _S_o_c_k_e_t    manpage.
  28.  
  29.      CCCCOOOONNNNSSSSTTTTRRRRUUUUCCCCTTTTOOOORRRR
  30.       new (    [ARGS] )
  31.           Creates an IO::Socket, which is a    reference to a newly
  32.           created symbol (see the Symbol package). new optionally
  33.           takes arguments, these arguments are in key-value    pairs.
  34.           new only looks for one key Domain    which tells new    which
  35.           domain the socket    will be    in. All    other arguments    will
  36.           be passed    to the configuration method of the package for
  37.           that domain, See below.
  38.  
  39.           IO::Sockets will be in autoflush mode after creation.
  40.           Note that    versions of IO::Socket prior to    1.1603 (as
  41.           shipped with Perl    5.004_04) did not do this.   So    if you
  42.           need backward compatibility, you should set autoflush
  43.           explicitly.
  44.  
  45.      MMMMEEEETTTTHHHHOOOODDDDSSSS
  46.       See the _p_e_r_l_f_u_n_c manpage for complete    descriptions of    each
  47.       of the following supported IO::Socket    methods, which are
  48.       just front ends for the corresponding    built-in functions:
  49.  
  50.           socket
  51.           socketpair
  52.           bind
  53.           listen
  54.           accept
  55.           send
  56.           recv
  57.           peername (getpeername)
  58.           sockname (getsockname)
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))
  71.  
  72.  
  73.  
  74.       Some methods take slightly different arguments to those
  75.       defined in the _p_e_r_l_f_u_n_c manpage in attempt to    make the
  76.       interface more flexible. These are
  77.  
  78.       accept([PKG])
  79.           perform the system call accept on    the socket and return
  80.           a    new object. The    new object will    be created in the same
  81.           class as the listen socket, unless PKG is    specified.
  82.           This object can be used to communicate with the client
  83.           that was trying to connect. In a scalar context the new
  84.           socket is    returned, or undef upon    failure. In an array
  85.           context a    two-element array is returned containing the
  86.           new socket and the peer address, the list    will be    empty
  87.           upon failure.
  88.  
  89.           Additional methods that are provided are
  90.  
  91.       timeout([VAL])
  92.           Set or get the timeout value associated with this
  93.           socket. If called    without    any arguments then the current
  94.           setting is returned. If called with an argument the
  95.           current setting is changed and the previous value
  96.           returned.
  97.  
  98.       sockopt(OPT [, VAL])
  99.           Unified method to    both set and get options in the
  100.           SOL_SOCKET level.    If called with one argument then
  101.           getsockopt is called, otherwise setsockopt is called.
  102.  
  103.       sockdomain
  104.           Returns the numerical number for the socket domain type.
  105.           For example, for a AF_INET socket    the value of &AF_INET
  106.           will be returned.
  107.  
  108.       socktype
  109.           Returns the numerical number for the socket type.    For
  110.           example, for a SOCK_STREAM socket    the value of
  111.           &SOCK_STREAM will    be returned.
  112.  
  113.       protocol
  114.           Returns the numerical number for the protocol being used
  115.           on the socket, if    known. If the protocol is unknown, as
  116.           with an AF_UNIX socket, zero is returned.
  117.  
  118.      SSSSUUUUBBBB----CCCCLLLLAAAASSSSSSSSEEEESSSS
  119.       IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt::::::::IIIINNNNEEEETTTT
  120.  
  121.       IO::Socket::INET provides a constructor to create an AF_INET
  122.       domain socket    and some related methods. The constructor can
  123.       take the following options
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))
  137.  
  138.  
  139.  
  140.           PeerAddr      Remote host address           <hostname>[:<port>]
  141.           PeerPort      Remote port or service       <service>[(<no>)] | <no>
  142.           LocalAddr      Local    host bind address      hostname[:port]
  143.           LocalPort      Local    host bind port           <service>[(<no>)] | <no>
  144.           Proto      Protocol name    (or number)    "tcp" | "udp" | ...
  145.           Type      Socket type               SOCK_STREAM | SOCK_DGRAM    | ...
  146.           Listen      Queue    size for listen
  147.           Reuse      Set SO_REUSEADDR before binding
  148.           Timeout      Timeout value    for various operations
  149.  
  150.       If Listen is defined then a listen socket is created,    else
  151.       if the socket    type, which is derived from the    protocol, is
  152.       SOCK_STREAM then _c_o_n_n_e_c_t() is    called.
  153.  
  154.       The PeerAddr can be a    hostname or the    IP-address on the
  155.       "xx.xx.xx.xx"    form.  The PeerPort can    be a number or a
  156.       symbolic service name.  The service name might be followed
  157.       by a number in parenthesis which is used if the service is
  158.       not known by the system.  The    PeerPort specification can
  159.       also be embedded in the PeerAddr by preceding    it with    a ":".
  160.  
  161.       If Proto is not given    and you    specify    a symbolic PeerPort
  162.       port,    then the constructor will try to derive    Proto from the
  163.       service name.     As a last resort Proto    "tcp" is assumed.  The
  164.       Type parameter will be deduced from Proto if not specified.
  165.  
  166.       If the constructor is    only passed a single argument, it is
  167.       assumed to be    a PeerAddr specification.
  168.  
  169.       Examples:
  170.  
  171.          $sock = IO::Socket::INET->new(PeerAddr => 'www.perl.org',
  172.                        PeerPort => 'http(80)',
  173.                        Proto    => 'tcp');
  174.  
  175.          $sock = IO::Socket::INET->new(PeerAddr => 'localhost:smtp(25)');
  176.  
  177.          $sock = IO::Socket::INET->new(Listen    =>    5,
  178.                        LocalAddr =>    'localhost',
  179.                        LocalPort =>    9000,
  180.                        Proto     =>    'tcp');
  181.  
  182.          $sock = IO::Socket::INET->new('127.0.0.1:25');
  183.  
  184.  
  185.       MMMMEEEETTTTHHHHOOOODDDDSSSS
  186.  
  187.       sockaddr ()
  188.           Return the address part of the sockaddr structure    for
  189.           the socket
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 10/23/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))
  203.  
  204.  
  205.  
  206.       sockport ()
  207.           Return the port number that the socket is    using on the
  208.           local host
  209.  
  210.       sockhost ()
  211.           Return the address part of the sockaddr structure    for
  212.           the socket in a text form    xx.xx.xx.xx
  213.  
  214.       peeraddr ()
  215.           Return the address part of the sockaddr structure    for
  216.           the socket on the    peer host
  217.  
  218.       peerport ()
  219.           Return the port number for the socket on the peer    host.
  220.  
  221.       peerhost ()
  222.           Return the address part of the sockaddr structure    for
  223.           the socket on the    peer host in a text form xx.xx.xx.xx
  224.  
  225.       IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt::::::::UUUUNNNNIIIIXXXX
  226.  
  227.       IO::Socket::UNIX provides a constructor to create an AF_UNIX
  228.       domain socket    and some related methods. The constructor can
  229.       take the following options
  230.  
  231.           Type      Type of socket (eg SOCK_STREAM or SOCK_DGRAM)
  232.           Local      Path to local    fifo
  233.           Peer      Path to peer fifo
  234.           Listen      Create a listen socket
  235.  
  236.  
  237.       MMMMEEEETTTTHHHHOOOODDDDSSSS
  238.  
  239.       hostpath()
  240.           Returns the pathname to the fifo at the local end
  241.  
  242.       peerpath()
  243.           Returns the pathanme to the fifo at the peer end
  244.  
  245.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  246.       the _S_o_c_k_e_t manpage, the _I_O::_H_a_n_d_l_e manpage
  247.  
  248.      AAAAUUUUTTTTHHHHOOOORRRR
  249.       Graham Barr <_G_r_a_h_a_m._B_a_r_r@_t_i_u_k._t_i._c_o_m>
  250.  
  251.      CCCCOOOOPPPPYYYYRRRRIIIIGGGGHHHHTTTT
  252.       Copyright (c)    1996 Graham Barr. All rights reserved. This
  253.       program is free software; you    can redistribute it and/or
  254.       modify it under the same terms as Perl itself.
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                        (printed 10/23/98)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIOOOO::::::::SSSSoooocccckkkkeeeetttt((((3333))))
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.      Page 5                        (printed 10/23/98)
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.